﻿using AbpEntityFrameworkcore.DbContext;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpEntityFrameworkcore.DbContextDesignFac
{
    public class CustomDbContextDesignFac : IDesignTimeDbContextFactory<CustomDbContext>
    {
        string Customconnstr = Environment.GetEnvironmentVariable("HNXG_AGV", EnvironmentVariableTarget.Machine);
        //string Customconnstr = ConfigStaticHelper.GetDbConnect();
        public CustomDbContext CreateDbContext(string[] args)
        {


            DbContextOptionsBuilder<CustomDbContext> builder =
            new DbContextOptionsBuilder<CustomDbContext>();
            builder.UseSqlServer(Customconnstr);
            CustomDbContext ctx = new CustomDbContext(builder.Options);
            return ctx;
        }
    }
}
